package com.yanqu.road.server.cmd.wingroom.chakra;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.WingRoomChakraProto.WingRoomChakraProto;
import com.yanqu.road.pb.activity.DaoMuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.wingroom.WingRoomChakraModule;
import com.yanqu.road.server.manger.wingroom.WingRoomChakraMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = WingRoomChakraProto.WingRoomChakraVisitReqMsg.class, respMsg = WingRoomChakraProto.WingRoomChakraVisitRespMsg.class)
@Cmd(code = GameProtocol.S_CHAKRA_VISIT, desc = "命盘系统-拜访")
public class ChakraVisitCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        WingRoomChakraProto.WingRoomChakraVisitReqMsg reqMsg = WingRoomChakraProto.WingRoomChakraVisitReqMsg.parseFrom(packet.getBytes());
        try {
            WingRoomChakraMgr.visitUser(player, reqMsg);
        } catch (BusinessException e) {
            WingRoomChakraProto.WingRoomChakraVisitRespMsg.Builder respMsg = WingRoomChakraProto.WingRoomChakraVisitRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
            player.sendPacket(Protocol.U_CHAKRA_VISIT, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {
    }
}
